package org.example;

import java.util.TreeSet;

public class TreeSet_Demo4 {
    public static void main(String[] args) {
        TreeSet<Student2> ts=new TreeSet<>();
//Student2
        ts.add(new Student2("zhangsan",18,90,80,70));
        ts.add(new Student2("lisi",19,80,80,70));
        ts.add(new Student2("wangwu",20,70,80,70));
        ts.add(new Student2("zhaoliu",21,60,80,70));
        ts.add(new Student2("qianqi",22,50,80,70));

        double totalSum = 0;
        // 增强 for 循环遍历 TreeSet，查看每个学生的个人总成绩
        for (Student2 student : ts) {
            // 计算当前学生的个人总成绩
            double personalSum = student.getChinses() + student.getMath() + student.getEnglish();
            // 输出学生姓名和个人总成绩
            System.out.println(student.getName() + " 的个人总成绩: " + personalSum);
            // 累加个人总成绩到总总成绩
            totalSum += personalSum;
        }
        // 输出所有学生的总成绩
        System.out.println("所有学生的总成绩: " + totalSum);
    }
}
